home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
CEDITOR_
/
CEDITORA.C1
< prev
next >
Wrap
Text File
|
1990-06-11
|
4KB
|
154 lines
/******************************************************************************
CEditorApp.c
The Editor Application Class
This class implements a demo application for the CEditorDoc and CeditorPane
classes.
Written by Johan A. Goossens
CompuServe: 74010,2576
SUPERCLASS = CApplication.c
******************************************************************************/
#include <Commands.h>
#include <Global.h>
#include <CBartender.h>
#include "CEditorApp.h"
#include "CEditorDoc.h"
extern OSType gSignature;
extern CBartender *gBartender;
#define MENUtext 4
#define MENUstyle 12
#define MENUspace 13
#define MENUalign 14
#define strTaskName 1
#define cmdSelectAll 1999
#define textWindow 2000
#define aboutDialog 2000
/******************************************************************************
IEditorApp
Initialize a EditorApp object
******************************************************************************/
void CEditorApp::IEditorApp()
{
IApplication(4, 20000L, 2000L);
}
/******************************************************************************
SetUpFileParameters {OVERRIDE}
Set parameters used by the Standard File Package
******************************************************************************/
void CEditorApp::SetUpFileParameters()
{
inherited::SetUpFileParameters();
gSignature = 'Gedt';
sfNumTypes = 1;
sfFileTypes[0] = 'TEXT';
}
/******************************************************************************
SetUpMenus {OVERRIDE}
Setup the menus for the application. Currently the menus defined as
hierarchical in the resource file. The code for the menu handling methods
in this class and in other classes will work for regular and for
hierarchical menu structures.
******************************************************************************/
void CEditorApp::SetUpMenus()
{
inherited::SetUpMenus();
gBartender->SetDimOption(MENUtext, dimNONE);
AddResMenu(GetMHandle(MENUfont), 'FONT');
gBartender->SetDimOption(MENUfont, dimNONE);
gBartender->SetUnchecking(MENUfont, TRUE);
gBartender->SetDimOption(MENUsize, dimNONE);
gBartender->SetUnchecking(MENUsize, TRUE);
gBartender->SetDimOption(MENUstyle, dimNONE);
gBartender->SetUnchecking(MENUstyle, TRUE);
gBartender->SetDimOption(MENUalign, dimNONE);
gBartender->SetUnchecking(MENUalign, TRUE);
gBartender->SetDimOption(MENUspace, dimNONE);
gBartender->SetUnchecking(MENUspace, TRUE);
}
/******************************************************************************
CreateDocument {OVERRIDE}
Make a document. This message is sent when the user chooses the
"New" command.
******************************************************************************/
void CEditorApp::CreateDocument()
{
CEditorDoc *theDocument;
theDocument = new(CEditorDoc);
theDocument->IEditorDoc(this, textWindow, strTaskName, 800);
theDocument->NewFile();
}
/******************************************************************************
OpenDocument {OVERRIDE}
Open an existing file and create a document object for displaying
information. This message is sent when the user chooses the
"Open..." command or when the application was launched by
double-clicking on a file or selecting file(s) and choosing
"Open" from the Finder.
The macSFReply parameter is a record which contains information
about the file to open (name, volume number, etc.).
******************************************************************************/
void CEditorApp::OpenDocument(SFReply *macSFReply)
{
CEditorDoc *theDocument;
theDocument = new(CEditorDoc);
theDocument->IEditorDoc(this, textWindow, strTaskName, 800);
theDocument->OpenFile(macSFReply);
}
/******************************************************************************
DoCommand {OVERRIDE}
If the "About CEditor Demo" command is selected, display the
about dialog and wait for the user to get sick and tired of that
stupid picture.
******************************************************************************/
void CEditorApp::DoCommand(long theCommand)
{
DialogPtr theDialog;
int itemHit;
if (theCommand == cmdAbout)
{
theDialog = GetNewDialog(aboutDialog, NULL, (void *) -1);
ModalDialog(NULL, &itemHit);
DisposDialog(theDialog);
}
else
inherited::DoCommand(theCommand);
}